package com.john.sqwen.ecbc.core.shiro.utils;

import com.john.sqwen.ecbc.core.shiro.relam.UserRealm;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.mgt.RealmSecurityManager;

/**
 * @author john_sqwen
 * @packageName com.john.sqwen.ecbc.core.shiro.utils
 * @date 2022/4/24
 * @projectName ecbc-base
 * @Description AuthorizationUtils
 **/

public class AuthorizationUtils {
    /**
     * 清理所有用户授权信息缓存
     */
    public static void clearAllCachedAuthorizationInfo()
    {
        getUserRealm().clearAllCachedAuthorizationInfo();
    }

    /**
     * 获取自定义Realm
     */
    public static UserRealm getUserRealm()
    {
        RealmSecurityManager rsm = (RealmSecurityManager) SecurityUtils.getSecurityManager();
        return (UserRealm) rsm.getRealms().iterator().next();
    }
}
